<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/share/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>提现申请</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%@ include file="/WEB-INF/share/wechat.jsp"%>
</head>
<body>
	<%@ include file="/WEB-INF/share/wechattop.jsp"%>
	<div class="mui-content">
		<div class="mui-control-content mui-active">
			<div class="header">
				<h3>提现申请</h3>
			</div>
		</div>
		<form class="mui-input-group">
			<div class="mui-input-row">
				<label>最小提现金额</label> <input type="text" class="mui-input-clear"
					placeholder="" value="100" disabled>
			</div>
			<div class="mui-input-row">
				<label>可提现金额</label> <input type="text" class="mui-input-clear"
					placeholder="" value="${current.currentmoney}" disabled>
			</div>
			<div class="mui-input-row">
				<label>提现金额</label> <input type="text" class="mui-input-clear"
					name='money' id="money" placeholder="提款金额">
			</div>
			<div class="mui-input-row">
				<label>收款类型</label> <select name="sktype" id="sktype">
					<option value="1">支付宝</option>
					<option value="2">微信</option>
				</select>
			</div>
			<div class="mui-input-row">
				<label>收款账号</label> <input type="text" class="mui-input-clear"
					name='zhanghao' id="zhanghao" placeholder="支付宝账户或微信号">
			</div>
			<div class="mui-input-row">
				<label>验证名称</label> <input type="text" class="mui-input-clear"
					name='checkname' id="checkname" placeholder="验证的名称或姓名">
			</div>
			<div class="mui-input-row">
				<label>联系手机</label> <input type="text" class="mui-input-clear"
					name='mobi' id="mobi" placeholder="手机号码">
			</div>
			<div class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary"
					onclick="applysub()">提现</button>
			</div>
		</form>
		<div style="width: 100%; height: 50px"></div>
	</div>
	<%@ include file="/WEB-INF/share/wechatscript.jsp"%>
	<script>
		function applysub() {
			var money = $("#money").val();
			var zhanghao = $("#zhanghao").val();
			var mobi = $("#mobi").val();
			var sktype = $("#sktype").val();
			if (money == '') {
				layer.open({
					content : '金额不能为空',
					skin : 'msg',
					time : 2
				});
				return false;
			}
			 var regPos = /^\d+(\.\d+)?$/;
			 if(!regPos.test(money)){
					layer.open({
						content : '金额必须是正数字',
						skin : 'msg',
						time : 2
					});
					return false;
			}
			if (zhanghao == '') {
				layer.open({
					content : '账号不能为空',
					skin : 'msg',
					time : 2
				});
				return false;
			}
			if (mobi == '') {
				layer.open({
					content : '联系手机不能为空',
					skin : 'msg',
					time : 2
				});
				return false;
			}
			if (sktype == '') {
				layer.open({
					content : '收款类型不能为空',
					skin : 'msg',
					time : 2
				});
				return false;
			}
			$.ajax({
				type : "POST",
				url : "${ctx}/wx/saveapply",
				data : {
					money : money,
					account : zhanghao,
					tel : mobi,
					withtype : sktype,
					name:$('#checkname').val()
				},
				dataType : "json",
				success : function(data) {
					console.log(data);
					if (data.type === 1) {
						layer.open({
							content : data.message,
							skin : 'msg',
							time : 2
						});
						setTimeout(function() {
							location.href = '${ctx}/wx/index';
						}, 1000);
					}
					else
					layer.open({
						content : data.message,
						skin : 'msg',
						time : 2
					});
				}
			});
			return false;
		}
	</script>
</body>
</html>
